<?php
/** Copyright 2014 TinPhp Systems, Inc.
 * @author zhangxilian 2013-8-15
 */
if (!defined('IN_TINPHP')) {
	exit ('Access Denied');
}

require_once (TIN_APP_PATH . 'include/utils/GeoCodeUtil.php');
/**
 * 地区信息业务逻辑处理单元
 * @author ZhangXiLian
 */
class GeoLogic extends TinBaseLogic {

	private $geoDao;

	//必须要有一个构造函数
	public function GeoLogic() {        
		parent::__construct();	
        $this->logger->className = "GeoLogic";
		$this->geoDao = Tin::getDAO("AssignTable","SYS_GEO");
		$this->geoDaoView = Tin::getDAO("AssignView","V_SYS_GEO");
	}
	//必须要一个释放函数
	public function __destruct(){
		parent::__destruct();
		$this->geoDao = null;
	}
	/**
	 * 根据条件获取单条记录
	 * */
	public function getGeoItem($cols, $cond){
		return $this->geoDao->selectRowByCond($cols, $cond);
	}
	/** 根据条件获取所有记录
	 * */
	public function getGeoAll($cols, $cond){
		$cond .= " and status=2";
		$res = $this->geoDao->selectAll($cols, $cond);
		return $res;
	}
	/** 根据条件获取所有记录
	 * */
	public function getGeoChildAll($cols, $geocode){		
		$geoRange = GeoCodeUtil::getGeoCodeRange($geocode);
		$cond = "STATUS=2 AND GEO_CODE>=". $geoCode . " AND GEO_CODE<=" . $geoRange['last'];
		$res = $this->geoDao->selectAll($cols, $cond);
		return $res;
	}
	/** 查询视图 */
	public function getAllByParentGeo($cols, $cond) {
		$res = $this->geoDaoView->selectAll($cols, $cond);
		return $res;
	}

}//End Class
?>
